package com.honey.spring;

import java.io.File;

import com.honey.compilation.xml.Document;
import com.honey.compilation.xml.XmlElement;
import com.honey.core.utils.HexCode;
import com.honey.core.utils.IoUtility;

public class MakeApplicationContext {
	
	private static final String XMLNS = "http://www.springframework.org/schema/beans" ;
	
	private static final String XMLNS_AOP = "http://www.springframework.org/schema/aop";
	
	private static final String XMLNS_TX = "http://www.springframework.org/schema/tx";
	
	private static final String XMLNS_XSI = "http://www.w3.org/2001/XMLSchema-instance";
	
	private static final String XSI_SCHEMALOCATION  = "http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd";
	
	public void makeFile(File file){
		Document doc = new Document(null, (String)null); 
		XmlElement root = new XmlElement("beans");
		root.addAttribute("xmlns", XMLNS);
		root.addAttribute("xmlns:aop", XMLNS_AOP);
		root.addAttribute("xmlns:tx", XMLNS_TX);
		root.addAttribute("xmlns:xsi", XMLNS_XSI);
		root.addAttribute("xsi:schemaLocation", XSI_SCHEMALOCATION);
		root.addAttribute("checksum", new String(HexCode.encodeHex("Honey v3.0 Test ".getBytes())));
		//root.addComments(" create" );
		root.addNewLine();
		doc.setRootElement(root);
		
		IoUtility.saveToFile(file, doc.compiledContent().toString());
	}
}
